/**
 *
 */
package com.thx.web;

import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.thx.auth.User;
import com.thx.common.web.WebConstant;
import com.thx.user.UserProxy;

/**
 * @author balancejia
 *
 */
public class UserContextUtil {

	/**
	 * 从web环境中取得com.thx.auth.User对象
	 *
	 * @return
	 */
	public static User getUser() {

		HttpSession session = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getSession();
		com.thx.user.model.User user = (com.thx.user.model.User) session.getAttribute(WebConstant.KEY_USER);
		UserProxy userProxy = new UserProxy(user);

		return userProxy;

	}
}
